import { createStore, applyMiddleware } from 'redux';
import {thunk} from 'redux-thunk';
import promise from 'redux-promise';
import logger from 'redux-logger';
import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import rootReducers from '../reducers';

const pConfig = {
  key: 'root',
  storage: storage,
};

const myPersistReducer = persistReducer(pConfig, rootReducers);

// import { composeWithDevTools } from 'redux-devtools-extension';
// composeWithDevTools 在控制台可以查看数据
const store = createStore(myPersistReducer, applyMiddleware( promise, thunk, logger));
export const persistor = persistStore(store);

export default store;